/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.1  (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the
 * License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */
/**
 * Nudm_UEAU
 * UDM UE Authentication Service. � 2020, 3GPP Organizational Partners (ARIB,
 * ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
 *
 * The version of the OpenAPI document: 1.2.0-alpha.1
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator
 * (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
 * the class manually.
 */

#include "DeleteAuthApiImpl.h"
#include "logger.hpp"

using namespace oai::udm::config;
extern udm_config udm_cfg;
using namespace oai::udm::model;
namespace oai {
namespace udm {
namespace api {

DeleteAuthApiImpl::DeleteAuthApiImpl(
    std::shared_ptr<Pistache::Rest::Router> rtr, udm_app* udm_app_inst,
    std::string address)
    : DeleteAuthApi(rtr) {}

void DeleteAuthApiImpl::delete_auth(
    const std::string& supi, const std::string& authEventId,
    const AuthEvent& authEvent, Pistache::Http::ResponseWriter& response) {
  Logger::udm_ueau().info("Handle delete_auth()");

  nlohmann::json auth_response = {};
  Pistache::Http::Code code    = {};
  m_udm_app->handle_delete_auth(
      supi, authEventId, authEvent, auth_response, code);

  // Set content type
  if ((code == Pistache::Http::Code::Created) or
      (code == Pistache::Http::Code::Accepted) or
      (code == Pistache::Http::Code::Ok) or
      (code == Pistache::Http::Code::No_Content)) {
    response.headers().add<Pistache::Http::Header::ContentType>(
        Pistache::Http::Mime::MediaType("application/json"));
  } else {
    response.headers().add<Pistache::Http::Header::ContentType>(
        Pistache::Http::Mime::MediaType("application/problem+json"));
  }

  Logger::udm_ueau().info("Send response to AUSF");
  response.send(code, auth_response.dump().c_str());
}

}  // namespace api
}  // namespace udm
}  // namespace oai
